<template>

  <div id="app">
      <router-view v-if="isRouterAlive"></router-view>
  </div>

</template>

<script>
// import vheader from './components/header_top.vue'
import HomeView from "./views/HomeView.vue";

export default {
  name: 'App',
  beforeRouteEnter(to, from, next) {
    // 添加背景色 margin:0;padding:0是为了解决vue四周有白边的问题
    document.querySelector('body').setAttribute('style', 'margin:0;padding:0;')
    next()
  },
  beforeRouteLeave(to, from, next) {
    // 去除背景色
    document.querySelector('body').setAttribute('style', '')
    next()
  },

  provide() { // 注册一个方法
    return {
      reload: this.reload
    }
  },

  components: {
    HomeView,
  },
  data(){
    return{
      isRouterAlive: true
    }
  },
  methods:{
    reload() {
      this.isRouterAlive = false
      this.$nextTick(function() {
        this.isRouterAlive = true
      })
    }
  }
}
</script>
